DRAW Michael J. Mefford Draws graphics from DOS prompt or batch files ------------------------------------------------------- Purpose ------- Provides low-resolution (320 x 200) color or high- resolution (640 x 200) monochrome drawing capabilities on CGA, EGA and VGA systems, without the need to work in BASIC. Format ------ DRAW [/K] (Option I) DRAW string [/K] (Option II) DRAW filespec/F [/K] (Option III) Remarks ------- Entered at the DOS prompt with no arguments on the command line (Option I), DRAW looks in the current directory for a file named DRAW.DAT and executes the commands in that file. A sample DRAW.DAT file is included on this disk. The file can be examined, and similar files created, with a regular ASCII word processor. Alternatively, DRAW can be entered with a string of commands (Option II) for a simple graphic or with the name of a file consisting of commands (Option III). Any legal DOS filename may be used, and full path support is provided, but a /F terminator must be appended to the filename. An optional /K may be added to prevent a keystroke from halting execution. Example ------- You can get a feel for how DRAW operates by entering, at the DOS prompt: DRAW X0 C2 BU50 M+40,70 L80 M+40,-70 BD5 P2,2 This will create a red triangle in the middle of your screen. You can trace the specific steps in this command sequence by referring to The DRAW Command Set table below. The DRAW Command Set -------------------- Xn Change to low resolution 320X200 color graphics. If X is not found, the default is 640X200 high resolution black and white graphics. X must be the first character of the command line or the first character in a file. The palette will be changed to n, where n can be either zero or one. See C color command below for the color of each palette. K Do not poll the keyboard while drawing. If K is not found, any keystroke terminates the program. Sn Flood the screen color to pattern n. n must be a decimal number in the range 0-255, and represents an eight bit pattern. Normally this command is issued immediately after the X command (if present), to clear the screen with a background color other than black. For example, to clear to color red (2) in low resolution, the command is S170 (binary 10101010). color 320X200 640X200 0 0 0 1 85 255 2 170 NA 3 255 NA Pattern colors may also be used. For example, a pattern of half green and half black would be S58 (binary 01000100). In high resolution, each bit represents a dot, eight dots per byte. This is why only two colors (black or white) are available. In low resolution, there are two bits per dot, so four combinations can be represented. In the example here the sequence is 01 (green), 00 (black), 01 (green), 00 (black). See C (color) command below for complete coding of the colors. U,D,L,R,E,F,G,H These commands, followed by a number, will move in one of the following compass directions: U H | E \ | / \ | / \ | / L -- -- -- + -- -- -- R / | \ / | \ / | \ G | F D Mx,y Move x,y units either relative to the current position or to the absolute coordinates, x,y. If the x coordinate is prefaced with either a plus sign or minus sign, the move is relative. Otherwise, the move is absolute. Note, you do not need to include a plus sign in front of the y coordinate in a positive y move. Pp,b Paint the color p until the border color b is found. The paint originates from the current position. B Blank move. The move following a B will move the desired units without plotting points. The next command will then continue drawing. N No update. The draw command following an N command will plot points, but the position will not be updated. The next draw command will start at the same position as the last. Cn Change the color to n. All draws after a C command will be in color n. n can be 0 (black) or 1 (white) in high resolution and 0 to 3 in low resolution. In low resolution, the color is dependent on the palette. 320X200 640X200 color palette 0 palette 1 0 black black black 1 green cyan white 2 red magenta NA 3 yellow white NA Related programs ---------------- This disk also includes BLOAD, BSAVE, VIDMODE and PLAY programs which can be used with DRAW to create quite sophisticated presentations within batch files. The command BSAVE filespec saves a byte image of the screen buffer to a file (with optional drive and path specifications), and BLOAD filespec loads a saved image file back to the screen buffer. VIDMODE can be used in a batch file with BLOAD to set the appropriate display resolution (VIDMODE 4 for low res, VIDMODE 6 for high res). The PLAY utility plays a tune on the PC's speaker. Example ------- This disk includes the example DRAW and PLAY files MOVIE.DAT and STING.DAT so that you can try the this example. Create the following batch file, SAVE.BAT, using an ASCII word processor, EDLIN, or COPY CON: ECHO OFF DRAW MOVIE.DAT/F BSAVE PICTURE Enter SAVE and the batch file will create a saved screen image called PICTURE of the MOVIE.DAT drawing. Now, similarly create a second batch file, SHOW.BAT: ECHO OFF (turn off command display) VIDMODE 4 (select low res graphics) BLOAD PICTURE (load the image) PLAY STING.DAT/F (play the tune) PAUSE > NUL (wait for a keypress) VIDMODE 3 (back to text screen) If you now enter SHOW at the DOS prompt the picture of two con men will appear, with appropriate musical background. Pressing any keystroke will clear the display. Note ---- 1. The PAUSE > NUL line in SHOW.BAT waits for a keystroke without showing a message on the display. This will not work properly on DOS versions prior to DOS 3. BLOAD and BSAVE Save and reload the screen display ------------------------------------------------------- Purpose ------- Similar to the BASIC commands of the same name, these two programs provide a simple ability to save and reload screen displays. They are included here for use with the DRAW program. Format ------ BSAVE filename then BLOAD filename Remarks ------- BSAVE stores the currently displayed screen in a file. The BLOAD command can then be used to reload it. If the screen is a graphic image, you should use the VIDMODE command included on this disk to set the appropriate display mode before using BLOAD. BLOAD and BSAVE can be used in batch files to quickly display complete screens or drawings. See the DRAW command for more information. PLAY Michael J. Mefford Plays tones and tunes on the PC's speaker ------------------------------------------------------- Purpose ------- Provides many of the music-producing functions of the BASIC PLAY statement without the need to work in BASIC. Format ------ PLAY[/K] (Option I) PLAY string[/K] (Option II) PLAY filespec/F[/K] (Option III) Remarks ------- Entered at the DOS prompt with no arguments on the command line (Option I), PLAY looks in the current directory for a file named PLAY.DAT and executes the commands in that file. The PLAY.DAT file included on this disk is "Greensleeves." The file can be examined, and similar files created, with a regular ASCII word processor. Alternatively, PLAY can use either a command-line string (Option II) or any legal DOS filename (Option III) to supply the music command arguments. Filenames may include a path designation, but must include the /F terminator. A sample file "score," STING.DAT is contained on this disk. Pressing any key while PLAY is executing will terminate operation unless the /K switch has been added. The command set used with PLAY is shown on the following page and is exemplified in the PLAY.DAT and STING.DAT files. The PLAY Command Set -------------------- K Keyboard. K will cause PLAY not to poll the keyboard during play. If K is not found, any keystroke will exit. On Octave. n is a decimal number between 0 and 6. Middle C starts 03. The default is 04. Ln Length of time the notes will be played until the next L command is encountered. n is a decimal number between 1 and 64. For example, L4 = quarter-note and L8 = eighth note. Tn Tempo is the pace at which the music is played. n is a decimal number between 32 and 255. The larger the number, the faster the pace. The default is T120. A-G Letter names corresponding to the notes of the scale. The letter name may be followed by either a # or + for a sharp, or a - for a flat. O3C = middle C. Nn Note to be played. n is a decimal number between 1 and 84. Each increment is 1/12 of an octave. N can be used as an alternative to defining a note by a letter and an octave. For example, N37 = middle C. Pn Pause, or rest, for a length defined by n. P works in the same way as the L command above. For example, P2 = a half rest. MN Music Normal. The note is played 7/8 of its specified time, and 1/8 is a rest between notes. This is the default. ML Music Legato. The note is played the full length of time specified. MS Music Staccato. The note is played 3/4 of the time specified, and 1/4 is a rest between notes. . Dot. A dot can follow a letter note or a pause. A dotted note increases play time by half the duration of the note or pause. More than one dot may be used. VIDMODE Charles Petzold Sets/displays the current video mode ------------------------------------------------------- Purpose ------- Reports/changes the current video mode. Format ------ VIDMODE m Remarks ------- Entered without the optional m parameter, VIDMODE displays the current video mode. In text modes, the commands VIDMODE 03 and VIDMODE 07 have the same practical effect as the DOS commands MODE CO80 and MODE MONO respectively. The table below lists the m (mode) parameters to which VIDMODE can be switched. Mode Type Disp. Resol. Chars Box Colors Pgs. ---- ---- ----- ------- ----- --- ------ --- 0&1 Text CGA 200x320 25x40 8x8 16 8 EGA 350x320 25x40 14x8 16 8 VGA 400x360 25x80 16x9 16 8 2&3 Text CGA 200x640 25x80 8x8 16 8 EGA 350x640 25x80 14x8 16 8 VGA 400x720 25x80 16x9 16 8 4&5 Graph CGA+ 200x320 25x40 8x8 4 1 6 Graph CGA+ 200x640 25x80 14x8 2 1 7 Text MDA 350x720 25x80 14x9 4 8 8-12 ------------ Reserved/PCjr modes ------------ 13 Graph EGA+ 200x320 25x40 8x8 16 8 14 Graph EGA+ 200x640 25x80 8x8 16 4 15 Graph EGA 350x640 25x80 14x8 4 1 16 Graph EGA+ 350x640 25x80 14x8 16 2 17 Graph MCGA+ 480x640 25x80 14x8 2 1 18 Graph VGA 480x640 25x80 14x8 16 1 19 Graph MCGA+ 200x320 25x40 14x8 256 1 Notes ----- 1. Users of a Hercules graphics card can activate "page 1" graphics if an EGA/VGA is installed with the command sequence: MODE CO80 VIDMODE 16 ... MODE MONO Use VIDMODE 14 if your EGA is connected to a conventional color monitor. 2. Should you switch to a mode not supported by your monitor, you can recover by blindly entering VIDMODE 3 (color) or VIDMODE 7 (monochrome). 3. By adding 128 to the mode number desired you can change modes without clearing the screen (though the cursor is reset to the upper left). These high numbered modes may confuse some applications programs, however. 4. VIDMODE will switch to 'super VGA' modes if your display has them provided that you know the correct mode number to use. Your display card manual should list these. WARNING: You should be careful not to select Super VGA modes that your monitor is not designed to handle. Some Super VGA cards do not provide protection against this and it can cause damage to your monitor. 5. VIDMODE was formerly called EGAMODE. @@VIDPAGE VIDPAGE Charles Petzold Sets/displays the current video page ------------------------------------------------------- Purpose ------- Reports/changes the current video page. Format ------ VIDPAGE p Remarks ------- Entered without the optional p parameter, VIDPAGE reports which video page is currently active. The chart presented in this manual for VIDMODE shows which video pages (p parameters, beginning with 0) can be used in each mode. VIDPAGE can be useful when you have material on your screen to which you want to return later. Entering VIDPAGE 1 activates a new screen while retaining the contents of the default VIDPAGE 0 in memory. The previous display can subsequently be recalled by issuing the VIDPAGE 0 command. Notes ----- 1. When using an alternate video page do not change video modes (e.g. with MODE CO80) or the previous display contents will be lost. 2. ANSI.SYS cannot be used with other than video page 0. 3. VIDPAGE was formerly called EGAPAGE